{include file="public/header"}
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>全部文件</title>
    <link rel="stylesheet" type="text/css" href="__CSS__/tt.css" />
    <link href="__JSS__/plugins/zTree/zTreeStyle.css" rel="stylesheet" >
    <link rel="stylesheet" href="__JSS__/plugins/webuploader/webuploader.css" ><!--webUploader上传组件-->
    <link rel="stylesheet" href="__JSS__/plugins/webuploader/style.css" ><!--webUploader上传组件-->
    <!--<link href="__JSS__/plugins/layui/css/layui.css" rel="stylesheet">-->
    <style>
        html,body {
            width: 100%;
            background:rgba(238,238,238,1);
            max-height: 500px;
        }

        .container{
            padding-top:30px;
            padding-bottom:94px;
        }


        .box{
            width:1200px;
            height:auto;
            margin: 0 auto;
            padding-bottom:10px;
            background-color:#FFFFFF;
        }

        .box_1{
            padding-left:30px;
            padding-right:30px;
            height: 66px;
        }


        table{
            width:100%;
            padding-left:30px;
            padding-right:30px;
            text-align:left;
            border-spacing:0;
            color:#666666;
            font-size:12px;
        }

        th{
            height:50px;
            line-height:50px;
            background-color:#F7F7F7;
            word-wrap:break-word;
            /*padding-left: 2px;*/
            /*padding-right: 2px;*/
        }
        th:nth-child(1){
            padding-left:30px;
        }
        td{
            height:50px;
            line-height:50px;
            border-bottom:1px solid #E9E9E9;
            word-wrap:break-word;
            overflow: hidden;
        }
        .td_special{
            display: -webkit-box;
            overflow: hidden;
            text-overflow: ellipsis;
            word-wrap: break-word;
            word-break: break-all;
            white-space: normal !important;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
        }
        .typeImg{
            /*margin-bottom: -10px;*/
        }
        td:nth-child(1){
            padding-left:30px;
        }
        td:hover{
            /*color: cornflowerblue;*/
            background: #F4FBFF;
        }
        td span:hover{
            color: cornflowerblue;
            /*background: #F4FBFF;*/
        }
        .name111{
            width:24px;
            font-size:12px;
            font-weight:400;
            color:rgba(0,101,240,1);
            margin-right:7px;
            cursor: pointer;
        }

        .pagination{
            /*height: 28px !important;*/
            /*line-height:28px;*/
            /*margin-top:30px;*/
            /*padding-right:33px;*/
            color:#999;
            font-size:12px;
        }
        .pagination div{
            margin-left:5px;
            margin-right:5px;
        }
        .pagination div:nth-child(2){
            margin-right:15px;
        }
        .pagination div:nth-child(6){
            color:#282828;
        }
        .pagination div:nth-child(8){
            margin-left:15px;
        }

        .box_1Name{
            color: #4A4A4A;
            width:60px;
            font-size:14px;
            font-weight:400;
            line-height:66px;
            padding-right: 5px;
        }

        .inputttt{
            margin-top:19px;
            width:230px;
            height:28px;
            background:rgba(255,255,255,1);
            border-radius:3px;
            border:1px solid rgba(244,244,244,1);
            color:rgba(204,204,204,1);
            font-size:12px;
        }

        .inputrenwu {
            padding-left: 11px;
            box-sizing: border-box;
            display: inline-block !important;
            width: 200px !important;
            height: 28px !important;
            outline: none;
            border-width: 0;
        }

        .inputtttImg{
            width: 16px;
            height: 16px;
            margin-top:6px;
            margin-left:5px;
        }
        .selectttt22{
            margin-top:20px;
            margin-left:30px;
            width:68px;
            height:30px;
            background:dodgerblue;
            border-radius:3px;
            text-align: center;
            line-height:30px;
            font-size:12px;
            font-weight:400;
            color:rgba(255,255,255,1);
        }
        .selectfile{
            margin-top:20px;
            width:80px;
            height:30px;
            background:dodgerblue;
            border-radius:3px;
            text-align: center;
            line-height:30px;
            font-size:12px;
            font-weight:400;
            color:rgba(255,255,255,1);
        }
        .selectfile2{
            height:60px;
            width:78px;
            color: dodgerblue;
            background:#FFF;
            border: 1px solid deepskyblue;
            margin: 0;
            padding: 0;
        }
        .selectfile3{
            width:120px;
            height: 28px;
            margin-left: 10px;
            color: dodgerblue;
            background:#FFF;
            border: 1px solid deepskyblue;
        }
        /*.uploadfile{*/
            /*background-image:url('__IMG__/upload.png');*/
            /*background-size: auto;*/
        /*}*/
        .selectfileson{
            margin:0;
            cursor: pointer;
        }
        .selectfileson:hover{
            background: powderblue;
            margin: 0;
        }

        .selectttt3{
            margin-top:19px;
            width:50px;
            height:28px;
            background:rgba(0,101,240,1);
            border-radius:3px;
            text-align: center;
            line-height:28px;
            font-size:12px;
            font-weight:400;
            color:rgba(255,255,255,1);float: left;
        }
        .hidden{
            display: none
        }
    </style>
    <style>
        .btn-primary {
            background-color: #1ab394;
            border-color: #1ab394;
            color: #FFF;
        }
        .btn {
            border-radius: 3px;
        }
        .btn-block {
            display: block;
            margin: 0 auto;
            width: 100px;
        }
        .btn {
            display: inline-block;
            padding: 6px 12px;
            margin-bottom: 0;
            font-size: 14px;
            font-weight: normal;
            line-height: 1.42857143;
            text-align: center;
            white-space: nowrap;
            vertical-align: middle;
            -ms-touch-action: manipulation;
            touch-action: manipulation;
            cursor: pointer;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            background-image: none;
            border: 1px solid transparent;
            border-radius: 4px;
        }
    </style>
</head>
<body>
<!--<div class="tt_top3">-->
    <!--<div class="tt_top33">全部文件</div>-->
<!--</div>-->
<div class="container">
    <div class="box">
        <form id="alls">
            <div class="box_1 flex-wrap">
                <div class="box_1Name">文件名称</div>
                <div class="inputttt flex-wrap">
                    <input type="text" class="inputrenwu" name="search[]" value="{$search.0?:''}" placeholder="搜索文件">
                    <img src="__IMG__/search.png" class="inputtttImg"/>
                </div>
                <div class="selectttt22 hand_icon" id="search" style="background: deepskyblue">搜索</div>
                <!--上传、新建文件夹-->
                <div class="selectfile uploadfile" onmouseover="overthis()" onmouseout="getout()" style="margin-left: 50px;cursor: pointer">
                    <img src="__IMG__/upload.png" height="30" width="30" />上传
                </div>
                <div class="selectfile selectfile2 hidden" style="margin-left: -80px;margin-top: 49px">
                    <div class="selectfileson" onmouseover="overthis()" onmouseout="getout()" onclick="uploadImage(2);">上传文件</div>
                    <div class="selectfileson" onmouseover="overthis()" onmouseout="getout()" onclick="uploadImage(3);">上传图片</div>
                </div>
                <div class="selectfile selectfile3 hand_icon" onclick="addFileTop();">
                    <img src="__IMG__/newfile.png" height="24" width="24" /> 新建文件夹
                </div>
                <div class="flex-con"></div>
                <div class="selectttt3" onclick="copyOrMove(1,'');" style="cursor: pointer;margin-left: 10px">复制</div>
                <div class="selectttt3" onclick="copyOrMove(2,'');" style="cursor: pointer;margin-left: 10px">移动</div>
                <div class="selectttt3" onclick="donwladFile('');" style="cursor: pointer;margin-left: 10px">下载</div>
                <div class="selectttt3" onclick="delFile('');" style="cursor: pointer;margin-left: 10px">删除</div>
            </div>
        </form>
        <!--<div>-->
        <div class="box1" style="width: 100%;overflow-x: scroll;">
            {if $uy_id}<span style="color: royalblue;cursor: pointer;margin-left: 30px;line-height: 30px" onclick="history.go(-1)"><< 返回</span>{/if}
            <table style="width: 100%;overflow-x: scroll;">
                <tr>
                    <th><input type="checkbox" class="all_check" />&nbsp;&nbsp;文件名</th>
                    <th>大小</th>
                    <th>修改日期</th>
                    <th>操作</th>
                </tr>
                {if condition="!$data->isEmpty()"}
                {foreach name="data" item="vo"}
                <tr>
                    <td class="td_special">
                        <input type="checkbox" class="one_check" data-id="{$vo.uy_id}" />
                        &nbsp;&nbsp;
                        {if $vo.uy_type == 1}
                        <img class="typeImg" src="__IMG__/file.png" height="30" />
                        {elseif $vo.uy_type == 2}
                            {if stristr($vo.uy_url,'.pdf') || stristr($vo.uy_url,'.PDF')}
                            <img class="typeImg" src="__IMG__/pdf.png" height="30" />
                            {/if}
                            {if stristr($vo.uy_url,'.docx') || stristr($vo.uy_url,'.doc')}
                            <img class="typeImg" src="__IMG__/word.png" height="30" />
                            {/if}
                            {if stristr($vo.uy_url,'.xls') || stristr($vo.uy_url,'.xlsx')}
                            <img class="typeImg" src="__IMG__/xls.png" height="30" />
                            {/if}
                        {else /}
                        <img class="typeImg" src="__IMG__/png.png" height="30" />
                        {/if}
                        &nbsp;
                        <span style="cursor: pointer;" onclick="fileInfo({$vo.uy_id},{$vo.uy_type},'{$vo.uy_url}');">
                            {$vo.uy_name?:''}
                        </span>
                    </td>
                    <td style="width: 100px;">
                        {if $vo.uy_type == 1}
                            -
                        {else /}
                            {$vo.uy_size > 1024 ? round($vo.uy_size/1024,2) . 'M' : round($vo.uy_size) . 'K'}
                        {/if}
                    </td>
                    <td style="width: 150px;">{$vo.uy_update?:''}</td>
                    <td style="width: 260px;">
                        <span class="name111" onclick="fileInfo({$vo.uy_id},{$vo.uy_type},'{$vo.uy_url}');">详情</span>
                        <span class="name111" onclick="copyOrMove(1,{$vo.uy_id});">复制</span>
                        <span class="name111" onclick="copyOrMove(2,{$vo.uy_id});">移动</span>
                        <span class="name111" onclick="setNewName({$vo.uy_id},'{$vo.uy_name}');">重命名</span>
                        {if $vo.uy_type != 1}
                            <a href="/shop/Index/downloadOne?file_name={$vo.uy_url}" target="_blank"><span class="name111">下载</span></a>
                        {else /}
                            <span class="name111" onclick="donwladFile({$vo.uy_id});">下载</span>
                        {/if}
                        <span class="name111" onclick="delFile({$vo.uy_id});">删除</span>
                    </td>
                </tr>
                {/foreach}
                {else/}
                <tr>
                    <td colspan="13" style="text-align: center;">暂无数据 ！</span></td>
                </tr>
                {/if}

            </table>
        </div>
        <!--</div>-->
        <ul class="pagination flex-con" style="display: flex;justify-content: flex-end;">
            {$data->render()}
        </ul>
    </div>
</div>
<!-- 权限分配 -->
<div class="zTreeDemoBackground left" style="display: none;height: 300px;!important;max-height: 300px;!important;" id="role">
    <input type="hidden" id="nodeid" value="" />
    <div class="form-group">
        <div class="col-sm-5 col-sm-offset-2">
            <ul id="treeType" class="ztree"></ul>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-4 col-sm-offset-4" style="margin-bottom: 15px;text-align: center;">
            <input type="button" value="确定" class="btn btn-primary btn-block" id="postform" />
        </div>
    </div>
</div>
<input type="hidden" name="ids" id="ids" value="" />
<input type="hidden" name="typetype" id="typetype" value="" />
<!---->
<style>
    .all_div{
        display:none;
        width: 100%;
        height: 100%;
        position: fixed;
        z-index: 999;
        background: rgba(0,0,0,0.5);
        top: 0;
        left: 0;
        padding: 0;
        margin: 0;
        text-align: center;
    }
    .ovfHiden{
        overflow: hidden;
        height: 100%;
    }
</style>
<div class="all_div"></div>
<style>
    .container_one{
        width:520px;
        height:180px;
        background:#fff;
        box-shadow:0px 2px 8px 0px rgba(0,0,0,0.2);
        border-radius:5px 4px 4px 4px;
        position: fixed;
        top:0;
        left:0;
        right:0;
        bottom:0;
        margin:auto;
        z-index: 999;
    }
    .btnBox{
        width:100%;
        height:52px;
        position: absolute;;
        bottom:0;
        left:0;
        border-top:1px solid #E9E9E9;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        /*padding-top:10px;*/
    }
    .title{
        height:50px;
        line-height: 50px;
        font-size:16px;
        color:#333;
        padding-left:20px;
        border-bottom:1px solid #E9E9E9
    }
    .content{
        width:480px;
        height:50px;
        background:#fff;
        padding:0 20px;
    }
    button{
        width:88px;
        height:32px;
        line-height: 32px;
        text-align: center;
        font-size:14px;
        outline: none;
        border:0;
        margin-left:8px;
    }
    .cancel_one{
        border:1px solid #D9D9D9;
        border-radius:2px;
        background: rgba(0,0,0,0);
        color:#666666;
        cursor: pointer;
    }
    .sure_one{
        background:#2A63E7;
        border-radius:2px;
        cursor: pointer;
        color:#fff;
    }
    .newFileName{
        width:100%;
        height:30px;
        overflow-y: auto;
        padding:5px;
        border:1px solid #E9E9E9;
        background:rgba(0,0,0,0);
        border-radius:5px;
    }
</style>
<div class="container_one hidden">
    <div class="title">重命名</div>
    <div class="content" style="padding-top: 20px">
        <input class="newFileName" placeholder="请输入文件名">
        <input type="hidden" id="new_id" value="" />
    </div>
    <div class="btnBox">
        <button class="cancel_one">取 消</button>
        <button class="sure_one">确定</button>&nbsp;
    </div>
</div>
<!---->
<style>
    .layui-upload-list img{
        height: 100px;
    }
    .upimage{
        /*height: 230px;*/
    }
    #contt2{
        /*border: 1px solid red;*/
        position: absolute;
        top:200px;
        left:50%;
        margin-left: -25%;
        width:500px;
        z-index: 9999;
        background: #FFF;
    }
</style>
<div id="contt2" class="hidden">
    <div class="layui-form-item layui-col-md-offset1 layui-col-md8 upimage">
        <br/>
        <label class="layui-form-label">选择：</label>
        <input type="hidden" name="imagePdf" class="imagePdf" id="lay-img" lay-verify="image">
        <div class="layui-input-block">
            <div id="lay-upload">上传</div>
            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                预览：
                <div class="layui-upload-list" id="lay-list">
                </div>
            </blockquote>
        </div>
    </div>
    <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
        <div class="layui-input-block">
            <button class="layui-btn sureUpload">确定
            </button>
            <button class="layui-btn layui-btn-primary cancelUpload">取消</button>
        </div>
    </div>
</div>
<!---->
<!--是重命名还是新建文件夹：1重命名 2新建文件夹-->
<input type="hidden" id="new_fid" value="{$uy_id}" />
<input type="hidden" id="newNew" value="" />
<!---->
<input type="hidden" id="uploadType" value="" />
</body>
{include file="public/footer"}
<!--<script type="text/javascript" src="__JSS__/plugins/layui/layui.all.js"></script>-->
<script src="__JSS__/plugins/zTree/jquery.ztree.core-3.5.js"></script>
<script src="__JSS__/plugins/zTree/jquery.ztree.excheck-3.5.js"></script>
<script src="__JSS__/plugins/webuploader/webuploader.js"></script><!--webUploader上传组件-->
<script src="__JSS__/wk.js"></script>
<script src="__JSS__/plugins/viewer/viewer.js"></script>
<script type="text/javascript">
    layui.config({
        base: '/src/' //静态资源所在路径
    }).extend({
        index: 'index', //主入口模块
        interact : 'interact'//三级联动
    }).use(['index','interact']),function(){};
    /**
     * 复制、移动（单个或批量）
     */
    function copyOrMove(type,id) {
        $('.btn-block').removeClass('layui-disabled').removeAttr('disabled','disabled');
        getOrderIds(); //每次进来都要先重算下id的值，以防出错
        $('#typetype').val(type);
        if(id){ //单个直接赋值ids
            $('#ids').val(id);
        }
        var typename = '复制到';
        if(type == 2){
            typename = '移动到';
        }
        giveQx(typename);
    }
    /**
     * 下载（单个或批量）
     */
    function donwladFile(id) {
        if(id){
            window.open('/shop/Index/downloadLot?id=' + id);
        }else{
            getOrderIds();
            var uyids = $('#ids').val();
            if(uyids == ''){
                alert('请选择文件！');
                return false;
            }else{
                if(confirm('确定要下载吗？')){
                    window.open('/shop/Index/downloadLot?id=' + uyids);
                }
            }
        }
        getOrderIds(); //每次进来都要先重算下id的值，以防出错
        $('#typetype').val(type);
        if(id){ //单个直接赋值ids
            $('#ids').val(id);
        }
        var typename = '复制到';
        if(type == 2){
            typename = '移动到';
        }
        giveQx(typename);
    }
    /**
     * 详情或查看
     */
    function fileInfo(id,type,url) {
        if(type != 1){
            window.open(url);
        }else{
            window.location.href = '/shop/Index/indexInfo?uy_id=' + id;
        }
    }
    /**
     * 重命名
     */
    function setNewName(id,name) {
        $('#newNew').val(1);
        $('.title').text('重命名');
        //------------------
        $('#new_id').val(id);
        $('.newFileName').val(name);
        $('.container_one').removeClass('hidden');
        $('.all_div').css('display','block');
        $('html,body').addClass('ovfHiden');
    }
    /**
     * 上传图片
     */
    function uploadImage(type) {
        $('.imagePdf').val('');
        $('#lay-list').empty();
        //
        $('#uploadType').val(type);
        if(type == 2){
            wk.uploadImg({size:200,type:'PDF,pdf,doc,docx,xls,xlsx',url:"{:url('Upload/upload')}",video:2}); //文档
        }else{
            wk.uploadImg({size:200,type:'png,jpg,jpeg',url:"/shop/Upload/upload",domain:""});
        }
        $('#contt2').removeClass('hidden');
        $('.all_div').css('display','block');
        $('html,body').addClass('ovfHiden');
    }

    /**
     * 新建文件夹
     */
    function addFileTop() {
        $('#newNew').val(2);
        $('.title').text('新建文件夹');
        //------------------
        $('.newFileName').val('');
        $('.container_one').removeClass('hidden');
        $('.all_div').css('display','block');
        $('html,body').addClass('ovfHiden');
    }
    $('.sure_one').click(function () {
        var type = $('#newNew').val();
        var new_fid = $('#new_fid').val();
        var id = $('#new_id').val();
        var name = $('.newFileName').val().trim();
        if(name==''){
            alert('名字不能为空！');
            return false;
        }else{
            if(type == 1){
                ajaxUse('/shop/Index/updateName',id,name);
            }else{
                ajaxUse('/shop/Index/addFileTop',new_fid,name);
            }
        }
    });
    $('.sureUpload').click(function () {
        var name = $('.imagePdf').val(); //图片地址（含大小和名字）
        var type = $('#uploadType').val(); //类型，文档还是图片
        var new_fid = $('#new_fid').val(); //fid
        if(name==''){
            alert('上传文件不能为空！');
            return false;
        }else{
            ajaxUse('/shop/Index/addFile',new_fid,name+'&type='+type);
        }
    });
    /**
     * 删除文件
     */
    function delFile(id) {
        getOrderIds(); //每次进来都要先重算下id的值，以防出错
        if(id){ //单个直接赋值ids
            $('#ids').val(id);
        }
        var ids = $('#ids').val();
        if(ids == ''){
            alert('请至少选择一个！');
            return false;
        }else{
            if(confirm('确定要删除吗(可在回收站找回)？')){
                ajaxUse('/shop/Index/delFake',ids,'')
            }
        }
    }
    function ajaxUse(url,id,name) {
        $.ajax({
            url: url,
            data: 'id='+id+'&name='+name,
            type: 'POST',
            dataType: 'JSON',
            success: function (returnData) {
//                alert(returnData.msg);
                if(returnData.code == 200){
                    location.reload();
                }
            },
            error: function () {
                alert('数据出错，请刷新重试');
            }
        })
    }
    /*筛选*/
    $("#search,.inputtttImg").click(function () {
        var data = $("#alls").serialize();
        window.location.href = '/shop/Index/index?' + data;
    });
    $('.all_div,.cancel_one,.cancelUpload').click(function (event) {
        $('.container_one').addClass('hidden');
        $('#contt2').addClass('hidden');
        $('.all_div').css('display','none');
        $('html,body').removeClass('ovfHiden');
        event.stopPropagation();
    })
    function overthis(){
        $('.selectfile2').removeClass('hidden');
    }
    function getout(){
        $('.selectfile2').addClass('hidden');
    }
</script>
<script type="text/javascript">
    zNodes = '';
    var index = '';
    var index2 = '';
    var index222 = '';
    //分配权限
    function giveQx(typename){
        $("#nodeid").val('');
        var uyids = $('#ids').val();
        if(uyids == ''){
            alert('请选择文件！');
            return false;
        }
        //加载层
        index2 = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
        //获取权限信息
        $.getJSON('./giveAccess', {'type' : 'get'}, function(res){
            layer.close(index2);
            if(res.code == 200){
                zNodes = JSON.parse(res.data);  //将字符串转换成obj
                //页面层
                var index = wk.layer_show1(typename,$('#role'),400);
                //设置位置
                layer.style(index, {
                    top: '5%'
                });
                //设置zetree
                var setting = {
                    view: {
                        dblClickExpand: false,//是否双击展开
                        showLine: true,//设置为显示或隐藏线条
                        selectedMulti: false,//设置是否允许选择多个节点
                        expandSpeed: "slow",//节点展开动画速度  "slow"、 "normal"、"fast"
                        showIcon: true,//设置为显示或隐藏节点图标
                        // fontCss : {color:"red"},//个性化的文本样式
                    },
                    check:{
                        enable:true,//设置为接受简单数据格式
                        chkStyle: "radio",//复选框类型
                        chkboxType: { "Y": "ps", "N": "s" }//当一个节点被选中或未选中时，控制其父节点及其子节点自动选中或取消选中p:父节点  s:子节点
                    },
                    data: {
                        simpleData: {
                            enable: true,//将zTree的节点设置为接受简单数据格式
                        }
                    },
                    callback: {
                        onClick: onClick
                    }
                };

                $.fn.zTree.init($("#treeType"), setting, zNodes);
                var zTree = $.fn.zTree.getZTreeObj("treeType");
                zTree.expandAll(false);

            }else if(res.code == 100){
                wk.error(res.msg);
                return false;
            }
        });
    }
    function onClick(e,treeId, treeNode) {
        $("#nodeid").val(treeNode.id);
        var zTree = $.fn.zTree.getZTreeObj("treeType");
        zTree.expandNode(treeNode);
    }
    //确认复制或移动
    $("#postform").click(function(){
        var id = $("#nodeid").val();
        var ids = $("#ids").val();
        var type = $("#typetype").val();
        if(ids == ''){
            alert('请刷新！');
            return false;
        }else if(type == ''){
            alert('请刷新！');
            return false;
        }else{
            $('.btn-block').addClass('layui-disabled').attr('disabled','disabled');
            //加载层
            index222 = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            ajaxMoveCopy(id,ids,type);
        }
    });
    function ajaxMoveCopy(fid,ids,type) {
        $.post('./fileCopyMove', {'fid' : fid, 'ids' : ids, 'type' : type}, function(res){
            layer.closeAll();
            if(res.code == 200){
                wk.success(res.msg);
                location.reload();
            }else{
                wk.error(res.msg,'','$(".btn-block").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                return false;
            }
        }, 'json')
    }
</script>
<script>
    /**
     * 点击全选
     */
    $('.all_check').click(function () {
        if($(this).prop('checked')){
            $('input:checkbox').prop('checked',true);
        }else{
            $('input:checkbox').prop('checked',false);
        }
        getOrderIds();
    });
    /**
     * 点击单个
     */
    $('.one_check').click(function () {
        var all_length = $('.one_check').length;
        var check_length = $('.one_check:checked').length;
        if($(this).prop('checked')){
            if(check_length >= all_length){
                $('.all_check').prop('checked',true);
            }
        }else{
            if(check_length < all_length){
                $('.all_check').prop('checked',false);
            }
        }
        getOrderIds();
    });
    /**
     * 获取选中的order_id
     */
    function getOrderIds() {
        var oids = '';
        $('.one_check:checked').each(function (i,d) {
            oids += $(d).attr('data-id')+',';
        });
        $('#ids').val(oids);
    }
</script>
